<?php 
//管理员的修改
	include_once("./com.php");
		$aid=$_GET['aid'];
		$type=$_GET['type'];
		$sql="select * from admin where aid=$aid";
		$ser=mysql_query($sql);
		while ($list=mysql_fetch_assoc($ser)) {
			$ber[]=$list;	
		} 
		if(isset($_GET['sub'])){
		$aname=$_GET['aname'];
		 $pwd=$_GET['pwd'];
		 $atype=$_GET['atype'];
		 $phone=$_GET['phone'];
		 $ai=$_GET['aid'];
		$ins="update admin set aname='$aname',apassword='$pwd',atype='$atype',phone='$phone' where aid='$ai'";	
		 $hrt=mysql_query($ins);
		 if(mysql_affected_rows()>0){
		 	echo"<script>
		 	alert('修改成功')
		 	location.href='adm.php'
		 	</script>"; 
		 }else{
		 echo "<script>
			alert('修改失败')
			location.href='adm.php'
			</script>";
		 }
		}
	
?>
 <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理员</title>
<base target="_self">
<link rel="stylesheet" type="text/css" href="skin/css/base.css" />
<link rel="stylesheet" type="text/css" href="skin/css/main.css" />
</head>
<body leftmargin="8" topmargin='8'>
<table width="98%" align="center" border="0" cellpadding="3" cellspacing="1" bgcolor="#CBD8AC" style="margin-bottom:8px;margin-top:8px;">
  <tr>
    <td background="skin/images/frame/wbg.gif" bgcolor="#EEF4EA" class='title' colspan="2"><span><img src='skin/images/frame/arr3.gif' style='margin-right:10px;'>修改管理员</span></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>
		<table style="margin-bottom:8px;margin-top:8px;margin-left:20px;">
			<form action="" method="" >
				<?php foreach ($ber as $value){ ?>	
				<input type="hidden" name="aid" value="<?= $value['aid']?>">							
			 <tr>
				<td>用户名：</td><td><input type="text" name="aname" value="<?= $value['aname']?>"></td>	
			 </tr>
			 <tr>
				<td>密码：</td><td><input type="password" name="pwd" value="<?= $value['apassword']?>"></td>	
			 </tr>
			  <tr>
				 <td>联系方式:</td><td><input type="text" name="phone" value="<?= $value['phone']?>"></td>
			</tr>
			 <tr>
			 	<td>角色：</td>
			 	<td colspan="2" align="center">
				<select name="atype">
				
				   <option value=0 <?= $type==0?"selected":""?>>超级管理员</option>
				 
				   <option value=1 <?= $type==1?"selected":""?>>一级管理员</option>
				 
				   <option value=2 <?= $type==2?"selected":""?>>二级管理员</option>
				
				   <option value=3 <?= $type==3?"selected":""?>>三级管理员</option>		

				</select>
				</td>
			</tr>		
			 <tr>
				<td colspan="2" align="center" height="40px">
				<input type="submit" name="sub" value=" 修改 " class="coolbt2"></td>
			 </tr>
			<?php }?>
			</form>
		</table>
	</td>
  </tr>
</table>
</body>
</html>